package git.soulbgm.job;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * xxl job 演示
 *
 * @author SoulBGM
 * @date 2020-09-16
 */
@Component
public class XxlJobDemo {

    /**
     * 简单任务示例
     */
    @XxlJob("simpleTaskExample")
    public ReturnT<String> execute(String param) throws InterruptedException {
        XxlJobLogger.log("执行execute方法");
        for (int i = 0; i < 10; i++) {
            XxlJobLogger.log("输出" + i);
            TimeUnit.SECONDS.sleep(1);
        }
        return ReturnT.SUCCESS;
    }

}
